import  pygame
import os
class Image:
    def __init__(self,font_path,font_size):
        pygame.init()
        self.font = pygame.font.Font(font_path,font_size)

    def text2image(self,text,path='img/',name=''):

        rtext = self.font.render(text,True,(0,0,0),(255,255,255))
        if(name == ''):
            name = text
        pygame.image.save(rtext,'{}.png'.format(path+name))







font_path = 'fonts/unifont-13.0.06.ttf'
font_size = 16
char_scale = [[19968,40870]]


image = Image(font_path, font_size)
if not os.path.exists('./img'):
    os.makedirs('./img')

for scale in char_scale:
    for i in range(*scale):
        try:
            char_i = chr(i)
            print("\r{}:{}".format(i,char_i),end='')
            image.text2image(char_i,'./img/',str(i))
        except:
            image.text2image(' ', './img/', str(i))
